package com.woniuxy.run.user.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniuxy.ResponseResult;
import com.woniuxy.run.user.entity.Collection;
import com.woniuxy.run.user.mapper.CollectionMapper;
import com.woniuxy.run.user.service.feign.ShopFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 
 * @since 2021-03-23
 */
@RestController
@RequestMapping("/collection")
public class CollectionController {

    @Autowired
    private CollectionMapper mapper;
    @Autowired
    private ShopFeign shopFeign;

    //收藏店铺
    @GetMapping("/like")
    public ResponseResult like(int userid,int shopid){
        Collection collection = new Collection();
        collection.setUserid(userid);
        collection.setShopid(shopid);
        return mapper.insert(collection)>0 ? ResponseResult.SUCCESS : ResponseResult.ERR;
    }

    //查看收藏的店铺List<>
    @GetMapping("/look")
    public ResponseResult<Object> look(int userid){
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("userid",userid);
        List<Integer> list = mapper.list(userid);
        //调用商家服务的接口（根据shopid查询shop） 获取商家信息

        return null;
    }
}

